/**
 * 定义sidebar中的菜单项
 *
 * 一些约定:
 * 1.菜单最多3层;
 * 2.只有顶层的菜单可以带图标;
 * 3.只有"叶子"节点才能跳转;
 * 4.所有的key都不能重复;
 */

/*GWW
  加载后台返回的menu数据
*/

import React from 'react';
import ajax from '../../utils/ajax';
import globalConfig from '../../config.js';
var Menudata;

// const versionId = [
// 		{name: "版本管理",
// 		id: "28",
// 		mixId:"versions",
// 		sn: "versions",
// 		url: "/cms/manage/VersionManage"
// 		},
// 		{
// 		name: "ID管理",
// 		id: "29",
// 		mixId:"idmanage",
// 		sn: "idmanage",
// 		url: "/cms/manage/Idmanage"
// 	}
// ]
// 	const inter = {
// 		name: "接口管理",
// 		id: "29",
// 		mixId:"inter",
// 		sn: "inter",
// 		url: "/cms/manage/interfaceManage"
// 	}
const examples = [{
	name: "授信管理",
	id: "8",
	url: "#",
	mixId:"crediManagement",
	sn: "crediManagement",
	children: [
		{
			name: "人工审核查询",
			mixId: "saa",
			children: [],
			description: "人工审核查询",
			priority: 99,
			url: "/cms/manage/CreditManagement/ManualAuditQuery"
		},
		{
			name: "白名单管理",
			mixId: "saa1",
			children: [],
			description: "白名单管理",
			priority: 99,
			url: "/cms/manage/CreditManagement/WhiteListManagement"
		},
		{
			name: "黑名单管理",
			mixId: "saa2",
			children: [],
			description: "黑名单管理",
			priority: 99,
			url: "/cms/manage/CreditManagement/BlackListManagement"
		}
	]
}, {
	name: "借据管理",
	id: "9",
	url: "#",
	sn: "IOUs",
	mixId:"mhaas",
	children: [
		{
			name: "借据信息列表",
			mixId: "Iu",
			children: [],
			description: "借据信息列表",
			priority: 234,
			url: "/cms/manage/Ioumanagement/information"
		},
		{
			name: "订单信息列表",
			mixId: "Iu1",
			children: [],
			description: "订单信息列表",
			priority: 99,
			url: "/cms/manage/Ioumanagement/Order"
		},
		{
			name: "放款结构查询",
			mixId: "Iu2",
			children: [],
			description: "放款结构查询",
			priority: 99,
			url: "/cms/manage/Ioumanagement/Loan"
		}
	]
},
{
	name: "贷后管理",
	id: "8",
	url: "#",
	sn: "postloanmanagement",
	mixId:"postloanmanagement",
	children: [
		{
			name: "我的催收列表",
			mixId: "postloanmanagement_one",
			children: [],
			description: "我的催收列表",
			priority: 99,
			url: "/cms/manage/PostLoanManagement/Collection"
		},
		{
			name: "逾期列表",
			mixId: "postloanmanagement_two",
			children: [],
			description: "逾期列表",
			priority: 99,
			url: "/cms/manage/PostLoanManagement/Overdue"
		}
	]
}
];
// const mockDictionary = {
// 	description: "字典管理",
// 	id: 211985,
// 	mixId: "zdgl",
// 	children: [],
// 	name: "字典管理",
// 	priority: 99,
// 	sn: "DictionaryManage",
// 	url: "/cms/manage/commonconfig"
// }
// const mockFeedback = {
// 	description: "意见反馈",
// 	id: 222985,
// 	mixId: "yjfk",
// 	children: [],
// 	name: "意见反馈",
// 	priority: 99,
// 	sn: "Feedback",
// 	url: "/cms/manage/opinion"
// }

const url = `${globalConfig.getAPIPath()}/index`;  // 拼接要请求的url地址\
function initData() {
	ajax.get({
		url: url,
		async: false,
		success: function (result) {
			if (result.errorCode == 200) {
				// console.log(result.data.children)
				Menudata = result.data.children;
				// versionId.forEach((item)=>{
				// 	Menudata[2].children.push(item);
				// })		
				// Menudata[1].children.push(inter);
			}
			// examples.forEach(function (val) {
			// 	Menudata.push(val)
			// })
		}
	})
	// Menudata[1].children.push(mockDictionary);
	// Menudata[1].children.push(mockFeedback);
	addSideClass(Menudata, "DebtManage", "font_12px");
	console.log(Menudata);
	return Menudata;
}
function addSideClass(Menudata, sn, classname) {
	Menudata.forEach((value) => {
		if(value.sn == sn) {
			value.className = classname;
		}
	})
}
module.exports = initData();
